package com.king.platform.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {

  private static final Long MAX_AGE = 1800L;

  public void addCorsMappings(CorsRegistry registry) {

    registry.addMapping("/**").allowedOriginPatterns(new String[]{"*"}).allowedMethods(new String[]{"POST", "GET", "PUT", "OPTIONS", "DELETE"}).maxAge(MAX_AGE).allowedHeaders(new String[]{"*"}).exposedHeaders(new String[]{"Content-Disposition"}).allowCredentials(true);
  }
}
